<template>
  <router-view></router-view>
</template>

<script>
let timer
let week = ['One ', 'Two ', 'Three ', 'four ', 'fife ', 'six ', 'seven ']
// 初始化
for(let i of week){
  if(localStorage.getItem(i)==null){
    localStorage.setItem(i, 0)
  }
}

export default {
  created () {
    let newNum = localStorage.getItem("newNum")
    if(!newNum){
      newNum = new Date().getDay()
      localStorage.getItem("newNum", newNum)
    }
    if(newNum === new Date().getDay()){
      let newDay = localStorage.getItem("newDay")
      if(!newDay){
        localStorage.setItem("newDay", 0)
      }
      let num = Number(newDay)
      timer = setInterval(()=>{
        localStorage.setItem("newDay", num)
        localStorage.setItem(week[newNum-1], num)
        num++
      },1000)   
    }else{
      let num = 0
      setInterval(()=>{
        localStorage.setItem("newDay", num)
        localStorage.setItem(week[newNum-1], num)
        num++
      },1000)
    }
  },
  beforeUnmount(){
    clearInterval(timer)
  }
}

</script>

<style>
html, body, #app{height: 100%; width: 100%;}
#app{
  padding: 3vh 2vh 0 2vh;
  box-sizing: border-box;
  font-size: 3vh;
  background-color: antiquewhite;
  overflow-y: scroll;
}
*{
  margin: 0;
  padding: 0;
}
a{text-decoration: none;}
li{list-style: none;}
table{border-collapse: collapse;}
input, textarea, div, select{outline: none;}
*::-webkit-scrollbar{
  height: 0;
  width: 0;
}
</style>
